from typing import *


class Solution:
    def stoneGameVI(self, aliceValues: List[int], bobValues: List[int]) -> int:
        n = len(aliceValues)
        idx = [v for v in range(n)]
        idx.sort(key=lambda a: aliceValues[a] + bobValues[a], reverse=True)
        a = b = 0
        for i in range(n):
            if i & 1 == 0:
                a += aliceValues[idx[i]]
            else:
                b += bobValues[idx[i]]
        return -1 if b > a else int(a > b)
